<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  user_model.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-21.
//  Copyright 2011 lishuzu. All rights reserved.
// 


class Home_model extends CI_Model
{
		function __construct(){
			parent::__construct();
			$this->load->model('work_model');
			$this->load->model('user_model');
			$this->load->model('feed_model');
			$this->user = $this->session->userdata('user') ? $this->session->userdata('user') : '';
			$this->uid = $this->uri->segment(3) ? intval($this->uri->segment(3)) : $this->user['uid'];
		}
		
		function getworks(){
			$data = array();
			$data = $this->work_model->get_works('20','',$this->uid);
			return $data;
		}
		
		function get_feeds($uids){
			if ($uids) {
				//page
				$_SGLOBAL = $this->config->item('SGLOBAL');
				$_SGLOBAL['multipage_config']['base_url'] = base_url().'home/index/'.$this->uid;
				$_SGLOBAL['multipage_config']['uri_segment'] = '4';
				// $_SGLOBAL['multipage_config']['per_page'] = '2';
				$offset = $this->uri->segment($_SGLOBAL['multipage_config']['uri_segment']);
				$data = $this->feed_model->get_feeds($uids, $_SGLOBAL['multipage_config']['per_page'], $offset);
				if ($data) {
					//page
					$_SGLOBAL['multipage_config']['total_rows'] = $data['count'];
					$this->pagination->initialize($_SGLOBAL['multipage_config']);
					$multi = $this->pagination->create_links();
					$data['multi'] = $multi;
					return $data;
				}else{
					return array();
				}
			}
			return false;
		}
}
?>